

    var j$=jQuery.noConflict(); 
    
    
             /********************************************************
                 This function handles the colon in VisualForce Ids       
              ********************************************************/
                    function jq(myid)                
                        { 
                                
                           return '#' + myid.replace(/(:|\.)/g,'\\\$1');
                
                        }    

    
     j$(document).ready(function()
        {
        
               /**************************************
                    Sarissa for IE-9 compatibility
                **************************************/
               
               
                   if(Sarissa._SARISSA_IS_IE && parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE")+5)) >=8)
                         {    
                              window.XMLSerializer = function(){};      
                              window.XMLSerializer.prototype.serializeToString=function(oNode){return oNode.xml;}    
                        
                          }
                      
               /*************************************************
                     Function to Check for Special Characters
                **************************************************/
                      
                      
                        function isSpecialCharacterandNumber(s) 
                        
                            {
                        
                                  var iChars = "!@#$%^&*()+=-_[]\\\';,/{}|\":<>?0123456789";
                                  
                                  
                                    for (var i = 0; i < s.length; i++)
                                      {
                                     
                                      
                                        if (iChars.indexOf(s.charAt(i)) == -1)
                                          {
                                            return false;
                                          }
                                      }
                                  return true;
                            }
        
              
               /**********************************************************
                    Function to Check for Entered Text is Number or NOT
                ***********************************************************/
        
                        function IsNumber(s) 
                            
                            {
                            
                                      var iChars = "0123456789";
                                      
                                      
                                        for (var i = 0; i < s.length; i++)
                                          {
                                              if (iChars.indexOf(s.charAt(i)) == -1)
                                              {
                                                return true;
                                              }
                                          }
                                      return false;
                            }
                    
                /**********************************************************
                    Function to Check for Entered Text is Empty or NULL
                ***********************************************************/
        
                        function IsEmptyisNull(s) 
                            
                            {                                        
                                 if(s.length==0)
                                     {                                    
                                         return true;
                                     }
                                      return false;
                            }
                    
          
                
                 /******************************************
                      Function to Validate Name Field
                  ******************************************/
                
                
                            function validatename()
                                
                                {
                                    j$("#uname_err").hide();
                                    j$("#uname_err1").hide();
                               
                               
                              
                                    if(j$(jq(tfirstname)).val().length==0)
                                    
                                        {
                                             j$("#uname_err").show();
                                              return false;
                                        }
                                
                                    if(isSpecialCharacterandNumber(j$(jq(tfirstname)).val()))
                                
                                          {
                                              j$("#uname_err1").show();
                                              return false;
                                          }
                                        return true;
                                }
                    
                 /******************************************
                      Function to Validate EmailId
                  ******************************************/
                    
                    
                        function validateEmailID()
                                {          
                                    j$("#emailid_err").hide();
                                    j$("#emailid1_err").hide();    
                                    if(j$(jq(temailid)).val().length<=0)
                                    {                        
                                        
                                         j$("#emailid_err").show();          
                                        return false;
                                    }
                                    else
                                    {
                                        var stremail = (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,5})+$/).test(j$(jq(temailid)).val());
                                        if(stremail == false)
                                        {                        
                                           
                                            j$("#emailid1_err").show();    
                                            return false;
                                        }
                                    }            
                                    return true;
                                }
                    
                    
                    
                  /******************************************
                      Function to Validate Mobile
                  ******************************************/
                  
                      function validatemobile()
                          
                          {
                              j$("#mobile_err").hide();
                              j$("#mobile_err1").hide();
                              j$("#mobile_zero").hide();
                              j$("#mobile_max").hide();
                              
                              if(j$(jq(tmobile)).val().length==0)
                              
                                    {
                                        j$("#mobile_err").show();
                                        return false;
                                    }
                                    
                              if(IsNumber(j$(jq(tmobile)).val()))                             
                                  {
                                      j$("#mobile_err1").show();
                                      return false;
                                  }
                                
                          
                              return true;
                          }
                          
                  /******************************************
                      Function to Validate Country
                  ******************************************/
                     function validatecountry()
                     
                         {
                             j$("#country_err").hide();
                             var country= document.getElementById("j_id0:enq_form:countrycomponent_id:countrycomponent:countrylist_id");
                          
                            
                                  if(country.value=="None")
                                  
                                      {
                                          j$("#country_err").show();
                                          
                                                                             
                                          return false;
                                      }
                         
                             return true;
                         }
                  
                  /******************************************
                      Function to Validate Country
                  ******************************************/
                     function validatecity()
                     
                         {
                              j$("#city_err").hide();
                             var country= document.getElementById("j_id0:enq_form:countrycomponent_id:countrycomponent:countrylist_id");
                             var city=document.getElementById("j_id0:enq_form:citycomponet_id:citycomponent:citylist_id");
                         
                            
                          if( city.value=="None")
                          
                              {
                              
                               
                                   j$("#city_err").show();
                              
                                  return false;
                              }
                         
                             return true;
                         }
                  
                  
                      function validateprojectname()
                      
                          {
                          
                          
                          
                          
                                  return true;
                          }
                   
                  /******************************************
                         Action happens here Onclick
                  ******************************************/
                   
                    j$('#SubmitLeadLink').click(function() 
                            {
                            
                            if(validatename()&validateEmailID()&validatemobile()&validatecountry()&validatecity())
                                {
                               
                                    savelead();
                                 }
                        
                            });
                    
        });
        
                        // populate country codes ;default to India
                
                        function getCountryValue()
                        {        
                            var countrycode="";
                            var countryname = document.getElementById("j_id0:enq_form:countrycomponent_id:countrycomponent:countrylist_id").value;
                
                
                            if(countryname == "India")
                            {
                                document.getElementById("j_id0:enq_form:citycomponet_id:citycomponent:citylist_id").style.display = "block";
                                document.getElementById(tcitytext).style.display = "none";
                            }
                            else
                            {
                                document.getElementById("j_id0:enq_form:j_id254:citycomponent:citylist_id").style.display = "none";
                                document.getElementById(tcitytext).style.display = "block";
                            }
                            
                            if(countryname=="United States")countrycode = "001";
                            if(countryname=="Albania")countrycode = "00355";
                            if(countryname=="Algeria")countrycode = "00213";
                            if(countryname=="Angola")countrycode = "00244";
                            if(countryname=="Argentina")countrycode = "0054";
                            if(countryname=="Armenia")countrycode = "00374";
                            if(countryname=="Australia")countrycode = "0061";
                            if(countryname=="Austria")countrycode = "0043";
                            if(countryname=="Azerbaijan")countrycode = "00994";
                            if(countryname=="Bahamas")countrycode = "001242";
                            if(countryname=="Bahrain")countrycode = "001973";
                            if(countryname=="Bangladesh")countrycode = "00880";
                            if(countryname=="Belarus")countrycode = "00375";
                            if(countryname=="Belgium")countrycode = "0032";
                            if(countryname=="Benin")countrycode = "00229";
                            if(countryname=="Bermuda")countrycode = "001441";
                            if(countryname=="Bolivia")countrycode = "00591";
                            if(countryname=="Bosnia and Herzegovina")countrycode = "00387";
                            if(countryname=="Botswana")countrycode = "00267";
                            if(countryname=="Brazil")countrycode = "0055";
                            if(countryname=="Bulgaria")countrycode = "00359";
                            if(countryname=="Canada")countrycode = "001";
                            if(countryname=="Chile")countrycode = "0056";
                            if(countryname=="China")countrycode = "0086";
                            if(countryname=="Colombia")countrycode = "0057";
                            if(countryname=="Cook Islands")countrycode = "00682";
                            if(countryname=="Costa Rica")countrycode = "00506";
                            if(countryname=="Croatia")countrycode = "00385";
                            if(countryname=="Cyprus")countrycode = "00357";
                            if(countryname=="Czech Republic")countrycode = "00420";
                            if(countryname=="Denmark")countrycode = "0045";
                            if(countryname=="Dominican Republic")countrycode = "001809";
                            if(countryname=="Ecuador")countrycode = "00593";
                            if(countryname=="Egypt")countrycode = "0020";
                            if(countryname=="El Salvador")countrycode = "00503";
                            if(countryname=="Equatorial Guinea")countrycode = "00240";
                            if(countryname=="Estonia")countrycode = "00372";
                            if(countryname=="Ethiopia")countrycode = "00251";
                            if(countryname=="Faroe Islands")countrycode = "00298";
                            if(countryname=="Finland")countrycode = "00358";
                            if(countryname=="France")countrycode = "0033";
                            if(countryname=="French Polynesia")countrycode = "00689";
                            if(countryname=="Gabon")countrycode = "00241";
                            if(countryname=="Gambia")countrycode = "00220";
                            if(countryname=="Georgia")countrycode = "00995";
                            if(countryname=="Germany")countrycode = "0049";
                            if(countryname=="Ghana")countrycode = "00233";
                            if(countryname=="Gibraltar")countrycode = "00350";
                            if(countryname=="Greece")countrycode = "0030";
                            if(countryname=="Greenland")countrycode = "00299";
                            if(countryname=="Guatemala")countrycode = "00502";
                            if(countryname=="Honduras")countrycode = "00504";
                            if(countryname=="Hong Kong")countrycode = "00852";
                            if(countryname=="Hungary")countrycode = "0036";
                            if(countryname=="Iceland")countrycode = "00354";
                            if(countryname=="India")countrycode = "0091";
                            if(countryname=="Indonesia")countrycode = "0062";
                            if(countryname=="Iran")countrycode = "0098";
                            if(countryname=="Iraq")countrycode = "00964";
                            if(countryname=="Ireland")countrycode = "00353";
                            if(countryname=="Israel")countrycode = "00972";
                            if(countryname=="Italy")countrycode = "0039";
                            if(countryname=="Japan")countrycode = "0081";
                            if(countryname=="Jordan")countrycode = "00962";
                            if(countryname=="Kazakhstan")countrycode = "007";
                            if(countryname=="Kenya")countrycode = "00254";
                            if(countryname=="Korea")countrycode = "00850";
                            if(countryname=="Kuwait")countrycode = "00965";
                            if(countryname=="Kyrgyzstan")countrycode = "00965";
                            if(countryname=="Latvia")countrycode = "00371";
                            if(countryname=="Lebanon")countrycode = "00961";
                            if(countryname=="Liechtenstein")countrycode = "00423";
                            if(countryname=="Lithuania")countrycode = "00370";
                            if(countryname=="Luxembourg")countrycode = "00352";
                            if(countryname=="Macedonia")countrycode = "00389";
                            if(countryname=="Madagascar")countrycode = "00261";
                            if(countryname=="Malaysia")countrycode = "0060";
                            if(countryname=="Malta")countrycode = "00353";
                            if(countryname=="Mauritius")countrycode = "0020230";
                            if(countryname=="Mexico")countrycode = "0052";
                            if(countryname=="Moldova")countrycode = "00373";
                            if(countryname=="Morocco")countrycode = "00212";
                            if(countryname=="Namibia")countrycode = "00264";
                            if(countryname=="Nepal")countrycode = "00977";
                            if(countryname=="Netherlands")countrycode = "0031";
                            if(countryname=="Netherlands Antilles")countrycode = "00599";
                            if(countryname=="New Zealand")countrycode = "0064";
                            if(countryname=="Nicaragua")countrycode = "00505";
                            if(countryname=="Nigeria")countrycode = "00234";
                            if(countryname=="Norway")countrycode = "0047";
                            if(countryname=="Pakistan")countrycode = "0092";
                            if(countryname=="Panama")countrycode = "00507";
                            if(countryname=="Peru")countrycode = "0051";
                            if(countryname=="Philippines")countrycode = "0063";
                            if(countryname=="Poland")countrycode = "0048";
                            if(countryname=="Portugal")countrycode = "00351";
                            if(countryname=="Qatar")countrycode = "00974";
                            if(countryname=="Romania")countrycode = "0040";
                            if(countryname=="Russian Federation")countrycode = "007";
                            if(countryname=="Saudi Arabia")countrycode = "00966";
                            if(countryname=="Singapore")countrycode = "0065";
                            if(countryname=="Slovak Republic")countrycode = "00421";
                            if(countryname=="Slovenia")countrycode = "00386";
                            if(countryname=="South Africa")countrycode = "0027";
                            if(countryname=="Spain")countrycode = "0034";
                            if(countryname=="Sri Lanka")countrycode = "0094";
                            if(countryname=="Sultanate of Oman")countrycode = "00968";
                            if(countryname=="Sweden")countrycode = "0046";
                            if(countryname=="Switzerland")countrycode = "0041";
                            if(countryname=="Syria")countrycode = "00963";
                            if(countryname=="Taiwan")countrycode = "00886";
                            if(countryname=="Tanzania")countrycode = "00256";
                            if(countryname=="Thailand")countrycode = "0066";
                            if(countryname=="Timor-Leste")countrycode = "00670";
                            if(countryname=="Togo")countrycode = "00228";
                            if(countryname=="Trinidad and Tobago")countrycode = "001868";
                            if(countryname=="Tunisia")countrycode = "00216";
                            if(countryname=="Turkey")countrycode = "0090";
                            if(countryname=="Uganda")countrycode = "006254";
                            if(countryname=="Ukraine")countrycode = "00380";
                            if(countryname=="United Arab Emirates")countrycode = "00971";
                            if(countryname=="United Kingdom")countrycode = "0044";
                            if(countryname=="Uruguay")countrycode = "00598";
                            if(countryname=="Uzbekistan")countrycode = "00998";
                            if(countryname=="Venezuela")countrycode = "0058";
                            if(countryname=="Viet Nam")countrycode = "0084";
                            if(countryname=="Yemen")countrycode = "00967";
                            if(countryname=="Yugoslavia")countrycode = "00967";
                            if(countryname=="Zimbabwe")countrycode = "00263";          
                            if(countryname=="UAE")countrycode = "00971";
                            if(countryname=="American Samoa")countrycode = "001684";
                            if(countryname=="Andorra")countrycode = "00376";
                            if(countryname=="Anguilla")countrycode = "001264";
                            if(countryname=="Antarctica")countrycode = "00672";
                            if(countryname=="Antigua and Barbuda")countrycode = "001268";
                            if(countryname=="Aruba")countrycode = "00297";
                            if(countryname=="Barbados")countrycode = "001246";
                            if(countryname=="Belize")countrycode = "00501";
                            if(countryname=="Bhutan")countrycode = "00975";
                            if(countryname=="Bouvet Island")countrycode = "0047";
                            if(countryname=="British Indian Ocean Territory")countrycode = "001284";
                            if(countryname=="British Virgin Islands")countrycode = "001284";
                            if(countryname=="Brunei")countrycode = "00673";
                            if(countryname=="Burkina Faso")countrycode = "00226";
                            if(countryname=="Burundi")countrycode = "00257";
                            if(countryname=="Cambodia")countrycode = "00855";
                            if(countryname=="Cameroon")countrycode = "00238";
                            if(countryname=="Cape Verde")countrycode = "00238";
                            if(countryname=="Cayman Islands")countrycode = "001";
                            if(countryname=="Central African Republic")countrycode = "00236";
                            if(countryname=="Chad")countrycode = "00235";
                            if(countryname=="Christmas Island")countrycode = "006189";
                            if(countryname=="Cocos Islands")countrycode = "001161";
                            if(countryname=="Comoros")countrycode = "00269";
                            if(countryname=="Congo")countrycode = "00242";
                            if(countryname=="Cuba")countrycode = "0053";
                            if(countryname=="Djibouti")countrycode = "00253";
                            if(countryname=="Dominica")countrycode = "001767";
                            if(countryname=="Eritrea")countrycode = "00291";
                            if(countryname=="Falkland Islands")countrycode = "00500";
                            if(countryname=="Fiji")countrycode = "00679";
                            if(countryname=="French Guiana")countrycode = "00594";
                            if(countryname=="French Southern Territories")countrycode = "00689";
                            if(countryname=="Grenada")countrycode = "001473";
                            if(countryname=="Guadeloupe")countrycode = "00590";
                            if(countryname=="Guam")countrycode = "001671";
                            if(countryname=="Guinea")countrycode = "00224";
                            if(countryname=="Guinea-Bissau")countrycode = "00245";
                            if(countryname=="Guyana")countrycode = "00592";
                            if(countryname=="Haiti")countrycode = "00509";
                            if(countryname=="Heard and McDonald Islands")countrycode = "00509";
                            if(countryname=="Afghanistan")countrycode = "0093";
                            if(countryname=="Ivory Coast")countrycode = "00225";
                            if(countryname=="Jamaica")countrycode = "001876";
                            if(countryname=="Kiribati")countrycode = "00686";
                            if(countryname=="Laos")countrycode = "00856";
                            if(countryname=="Lesotho")countrycode = "00266";
                            if(countryname=="Liberia")countrycode = "00231";
                            if(countryname=="Libya")countrycode = "00218";
                            if(countryname=="Macau")countrycode = "00853";
                            if(countryname=="Malawi")countrycode = "00265";
                            if(countryname=="Maldives")countrycode = "00960";
                            if(countryname=="Mali")countrycode = "00223";
                            if(countryname=="Marshall Islands")countrycode = "00692";
                            if(countryname=="Martinique")countrycode = "00596";
                            if(countryname=="Mauritania")countrycode = "00222";
                            if(countryname=="Mayotte")countrycode = "00269";
                            if(countryname=="Micronesia")countrycode = "00691";
                            if(countryname=="Monaco")countrycode = "00377";
                            if(countryname=="Mongolia")countrycode = "00976";
                            if(countryname=="Montserrat")countrycode = "001664";
                            if(countryname=="Mozambique")countrycode = "00258";
                            if(countryname=="Myanmar")countrycode = "0095";
                            if(countryname=="Nauru")countrycode = "00674";
                            if(countryname=="New Caledonia")countrycode = "00687";
                            if(countryname=="Niger")countrycode = "00227";
                            if(countryname=="Niue")countrycode = "00683";
                            if(countryname=="Norfolk Island")countrycode = "006723";
                            if(countryname=="Northern Mariana Islands")countrycode = "001";
                            if(countryname=="Palau")countrycode = "00680";
                            if(countryname=="Papua New Guinea")countrycode = "00675";
                            if(countryname=="Paraguay")countrycode = "002595";
                            if(countryname=="Pitcairn Island")countrycode = "0063";
                            if(countryname=="Puerto Rico")countrycode = "001939";
                            if(countryname=="Reunion")countrycode = "00262";
                            if(countryname=="Rwanda")countrycode = "00250";
                            if(countryname=="S. Georgia and S. Sandwich Isls.")countrycode = "007";
                            if(countryname=="Saint Kitts and Nevis")countrycode = "001869";
                            if(countryname=="Saint Lucia")countrycode = "001758";
                            if(countryname=="Saint Vincent and The Grenadines")countrycode = "001";
                            if(countryname=="Samoa")countrycode = "00685";
                            if(countryname=="San Marino")countrycode = "00378";
                            if(countryname=="Sao Tome and Principe")countrycode = "00378";
                            if(countryname=="Senegal")countrycode = "00221";
                            if(countryname=="Seychelles")countrycode = "00248";
                            if(countryname=="Sierra Leone")countrycode = "00232";
                            if(countryname=="Slovakia")countrycode = "00421";
                            if(countryname=="Somalia")countrycode = "00252";
                            if(countryname=="St. Helena")countrycode = "00290";
                            if(countryname=="St. Pierre and Miquelon")countrycode = "00508";
                            if(countryname=="Sudan")countrycode = "00249";
                            if(countryname=="Suriname")countrycode = "00597";
                            if(countryname=="Svalbard and Jan Mayen Islands")countrycode = "00597";
                            if(countryname=="Swaziland")countrycode = "00268";
                            if(countryname=="Tajikistan")countrycode = "00992";
                            if(countryname=="Tokelau")countrycode = "00690";
                            if(countryname=="Tonga")countrycode = "00676";
                            if(countryname=="Turkmenistan")countrycode = "00993";
                            if(countryname=="Turks and Caicos Islands")countrycode = "001649";
                            if(countryname=="Tuvalu")countrycode = "00688";
                            if(countryname=="Vanuatu")countrycode = "00678";
                            if(countryname=="Vatican City")countrycode = "0039";
                            if(countryname=="Virgin Islands")countrycode = "001";
                            if(countryname=="Wallis and Futuna Islands")countrycode = "00681";
                            if(countryname=="Western Sahara")countrycode = "00681";
                            if(countryname=="Zaire")countrycode = "00243";
                            if(countryname=="Zambia")countrycode = "00260";
                            document.getElementById(tcountrycodemobile).value = countrycode;
                            document.getElementById(tcountrycodelandline).value = countrycode;
                        }
               
